<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::get('/info', function (Request $request) {
    return phpinfo();
});


//第三方api接口调用
Route::group(['prefix' => 'api'], function () {
    Route::post("api",'Api\BonusController@api');//logo查看
});

Route::group(['prefix' => 'auth'], function () {
    Route::post("message/code/",'Auth\JwtController@MsgCode');// 用户申请短信验证码
    Route::post("business/code/",'Auth\BusinessController@MsgCode');// 商家申请短信验证码
    Route::post("admin/code/",'Auth\AdminController@MsgCode');// 管理员申请短信验证码
    Route::post("user/token/",'Auth\JwtController@userLoginOrRegister');// 用户登录
    Route::post("business/token/",'Auth\BusinessController@BusinessLogin');// 商家登录
    Route::post("admin/token/",'Auth\AdminController@AdminLogin');// 后台管理员登录
});
Route::group(['prefix'=>'forget'],function (){
    Route::post("business/token/",'Auth\BusinessController@BusinessForget');// 商家忘记密码
    Route::post("admin/token/",'Auth\AdminController@AdminForget');// 后台管理员忘记密码
});
Route::group(['prefix' => 'logo','middleware'=>['token','access']], function () { //用户
    Route::post("index/",'Admin\LogoController@index');//logo查看
    Route::post("update/",'Admin\LogoController@update');//logo修改
});

Route::group(['prefix' => 'api'], function () {
    Route::post("files/",'Api\FilesController@store');//文件上传统一接口
});

//订单和订单优惠券相关信息 购物车相关信息
Route::group(['prefix' => 'order','middleware'=>['token','access']], function () {
    Route::resource('bonus/current', 'Order\BonusController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);

    Route::resource('bonus/record', 'Order\BonusRecordController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
//购物车
    Route::resource('cart', 'Order\CartController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
    Route::post("cart/delete",'Order\CartController@alldelete');//商品批量删除
    //订单
    Route::resource('order', 'Order\OrdersController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
});


Route::group(['prefix' => 'user'], function () { //用户

    Route::resource('info', 'User\UserInfoController', ['only' => [
        'store'
    ]]);
});
Route::group(['prefix' => 'user','middleware'=>['token','access']], function () { //用户

    Route::resource('info', 'User\UserInfoController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
    Route::post("info/delete",'User\UserInfoController@alldelete');//商家批量删除
});
Route::group(['prefix' => 'user','middleware'=>['token','access']], function () { //用户收藏

    Route::resource('collection', 'User\CollectionController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
});

Route::group(['prefix' => 'user','middleware'=>['token','access']], function () { //用户地址

    Route::resource('address', 'User\AddressController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
    Route::post("address/showone",'User\AddressController@showone');//用户地址查看多个
    Route::post("address/showstatus",'User\AddressController@showstatus');  //查看默认地址
});

Route::group(['prefix' => 'business','middleware'=>['token','access']], function () { //商家

    Route::resource('info', 'Business\BusinessInfoController', ['only' => [
        'index', 'show','update', 'destroy'
    ]]);
    Route::post("info/delete",'Business\BusinessInfoController@alldelete');//商家批量删除

});
Route::group(['prefix' => 'business'], function () { //商家
    Route::post("info/search",'Business\BusinessInfoController@search');//商家号重复
    Route::resource('info', 'Business\BusinessInfoController', ['only' => [
        'store'
    ]]);
});



Route::group(['prefix' => 'business','middleware'=>['access']], function () { //商家分类

    Route::resource('classification', 'Business\BusinessClassificationController', ['only' => [
        'index', 'show',
    ]]);
});
Route::group(['prefix' => 'business','middleware'=>['access','token']], function () { //商家分类

    Route::resource('classification', 'Business\BusinessClassificationController', ['only' => [
         'store', 'update', 'destroy'
    ]]);

});


Route::group(['prefix' => 'business','middleware'=>['token','access']], function () {  //营业时间

    Route::resource('time', 'Business\BusinessTimeController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
});

Route::group(['prefix' => 'food','middleware'=>['access','token']], function () {  //商品

    Route::resource('info', 'Business\FoodInfoController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
    Route::post("info/delete",'Business\FoodInfoController@alldelete');//商品批量删除
});


Route::group(['prefix' => 'food','middleware'=>['access','token']], function () {  //商品分类

    Route::resource('classification', 'Business\FoodClassificationController', ['only' => [
        'index', 'show','store', 'update', 'destroy'
    ]]);
});

Route::get("classification/search",'Business\FoodClassificationController@search');//主页搜索

Route::group(['prefix' => 'food','middleware'=>['access','token']], function () {  //类目

    Route::resource('category', 'Business\FoodCategoryController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy'
    ]]);
});


Route::group(['prefix' => 'order'], function () { // 订单失败原因

    Route::resource('because', 'Order\OrderBecauseController', ['only' => [
        'index', 'show'
    ]]);
});

Route::group(['prefix' => 'order'], function () { // 订单失败原因

    Route::resource('because', 'Order\OrderBecauseController', ['only' => [
        'store', 'update', 'destroy'
    ]]);
});
Route::group(['prefix' => 'order','middleware'=>['token','access']], function () { // 商家购物车

    Route::resource('business', 'Order\BusinessCartController', ['only' => [
        'index','store', 'show', 'destroy'
    ]]);
     Route::post("business/delete",'Order\BusinessCartController@alldelete');//商品批量删除
});
Route::group(['prefix' => 'order','middleware'=>['token','access']], function () { // 口味选择

    Route::resource('flavor', 'Order\FlavorController', ['only' => [
        'index','show','store', 'update', 'destroy'
    ]]);
});
Route::group(['prefix' => 'admin'], function () { // 后台地址

    Route::resource('address', 'Admin\AdminClassController', ['only' => [
        'index','show','store', 'update', 'destroy'
    ]]);
});

Route::group(['prefix' => 'sys'], function () {  //用户添加,管理员添加

    Route::post("user/store",'User\UserController@store');//用户添加
    Route::post("user/delete",'User\UserController@destroy');//用户删除
    Route::post("admin/store",'Admin\AdminController@store');//用户添加
    Route::post("admin/delete",'Admin\AdminController@destroy');//用户添加
});

Route::group(['prefix' => 'ws'], function () { // 口味选择

    Route::resource('index', 'workman\IndexController', ['only' => [
        'index'
    ]]);
});




